{% extends 'base.html' %}
{% block content %}

    <body>
        <div class="layui-fluid">
            <div class="layui-row">

                <form class="layui-form">
                    <div class="layui-form-item">
                        <label for="L_username" class="layui-form-label">所属父分类</label>
                        <div class="layui-input-inline">
                            <input value="{{post['fcate_name'] }}" type="text" id="p_cate" name="p_cate" disabled="disabled" lay-verify="title" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">子分类名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="s_cate" name="s_cate" required="" lay-verify="title" autocomplete="off" class="layui-input">
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="add" lay-submit >增加</button>
                    </div>
                </form>

            </div>
        </div>
        <script>
            layui.use(['form', 'layer','jquery'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //自定义验证规则
                form.verify({
                    title:[/\S/,'分类名不能为空'],
                });

                //监听提交
                form.on('submit(add)',
                function(data) {
                    console.log(data.field);
                    $.post(data.form.action,data.field);
                    //发异步，把数据提交给服务端
                    layer.alert("增加成功", {icon: 6},
                        function() {
                        //关闭当前frame
                        xadmin.close();
                        // 可以对父窗口进行刷新
                        xadmin.father_reload();

                    });
                    return false;

                });

            });
        </script>
    </body>
{% endblock %}